//var ballObj : UnityEngine.GameObject; 
var startingSpeed : float;
static var lifesLeft : int;
var canThrow : boolean;
static var balls : int = 0;

	// Use this for initialization
function Start () 
{
	lifesLeft = 5;
	gameObject.rigidbody.velocity = transform.TransformDirection(Vector3(1.5, 10, 0) * startingSpeed);
	canThrow = false;
	
	balls += 1;

}
	
// Update is called once per frame
function Update () 
{
	transform.position.z = 0;

	if(Input.GetButtonUp("Jump") && canThrow == true)
	{
		gameObject.rigidbody.velocity = transform.TransformDirection(Vector3(1.5, 10, 0) * startingSpeed);
		canThrow = false;
	}
}



function OnTriggerExit(d : Collider)
	{
		if(d.gameObject.tag == "bottom_border")
			{
			if(balls > 1)
				{	
					balls -= 1;
					gameObject.Destroy(gameObject);
			
				}
			else
				{
					lifesLeft--;
					transform.position.x =0;
					transform.position.y =0;
					transform.rigidbody.velocity = transform.TransformDirection(Vector3(0, 0, 0));
				}
			}
				if(lifesLeft > 0)
			{
				canThrow = true;
			}
		
	}